package cn.tansanqinger.controller.chatroom;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import cn.tansanqinger.service.chatroom.IFriendlistService;
import cn.tansanqinger.service.hymenu.IHyMenuServer;
import cn.tansanqinger.util.PageData;

@Controller
@RequestMapping("/exchange")
public class ExchangeIndexController {

	
	@Autowired
	private IHyMenuServer hyMenuServer;
	@Autowired
	private IFriendlistService fservice;
	
	@RequestMapping("/index")
	public ModelAndView index(ModelAndView mv, HttpServletRequest request) {
		mv = hyMenuServer.selectHyMenuAll(mv);
		mv.addObject("user", request.getSession().getAttribute("user"));
		mv.addObject("friendlist", fservice.selectMessage(request));
		mv.setViewName("chatroom/list");
		return mv;
	}
	
	@RequestMapping("/list")
	@ResponseBody
	public PageData list(HttpServletRequest request) {
		PageData pd = new PageData();
		pd.put("user", request.getSession().getAttribute("user"));
		pd.put("friendlist", fservice.selectMessage(request));
		return pd;
	}
	
	
	
	
}
